<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
  /**
  * 正数在左，负数在右
  * 不能开新数组
  */

    const arr = [-123, 33, 1, -5, 11, 23, -100, -200];

    function getArr(arr) {  
      let j = 0;
      for (let i = 0; i < arr.length; i++) {
        if (arr[i] > 0) {
          const num = arr[i];
          arr[i] = arr[j];
          arr[j] = num;
          j++;
        }
      }
      return arr
    }

    console.log(getArr(arr))</script>
</body>

</html>